import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument } from 'mongoose';

export type UserDocument = HydratedDocument<User>;

@Schema({
	timestamps: true, // 这会自动添加 createdAt 和 updatedAt 字段
})
export class User {
	@Prop({ required: true })
	name: string;

	@Prop({ required: true })
	age: number;
}

export const UserSchema = SchemaFactory.createForClass(User);

export const UserModel = {
	name: User.name,
	schema: UserSchema
}
